/**
 * @authors
 * @date
 * @version
 */
import * as service from '@/services/common';

export default {
  namespace: 'common',
  state: {
    datas: [],
  },
  effects: {
    /**
     * 上传富文本内复制的图片
     */
    *uploadContentImg({ payload, callback }: any, { call }: any): any {
      const response = yield call(service.uploadContentImg, payload);
      if (callback) callback(response);
    },

    *getSysDictListByTypeCode({ payload, callback }: any, { call }: any): any {
      const response = yield call(service.getSysDictListByTypeCodeNew, payload);
      if (callback) callback(response);
    },

    // 地区三级联动
    *getAreaListByPid({ payload, callback }: any, { call }: any): any {
      const response = yield call(service.getAreaListByPid, payload);
      if (callback) callback(response);
    },

    // 地区选择三级联动,根据末级查询完整树,传入末级id
    *getAreaTree({ payload, callback }: any, { call }: any): any {
      const response = yield call(service.getAreaTree, payload);
      if (callback) callback(response);
    },
    // 学校列表
    *getSchoolList({ payload, callback }: any, { call }: any) {
      const response = yield call(service.getSchoolList, payload);
      if (callback) {
        callback(response);
      }
    },

    // 系列表
    *getDepartmentList({ payload, callback }: any, { call }: any) {
      const response = yield call(service.getDepartmentList, payload);
      if (callback) {
        callback(response);
      }
    },
    // 专业列表
    *findMajorIdAndNameListByDeptId({ payload, callback }: any, { call }: any) {
      const response = yield call(service.findMajorIdAndNameListByDeptId, payload);
      if (callback) {
        callback(response);
      }
    },
    // 根据学校id查询专业
    *majorListTree({ payload, callback }: any, { call }: any): any {
      const response = yield call(service.majorListTree, payload);
      if (callback) callback(response);
    },
    
    // 选人组件 - 老师专业列表
    *getMajorIdByTeacherId({ payload, callback }: any, { call }: any): any {
      const response = yield call(service.getMajorIdByTeacherId, payload);
      if (callback) callback(response);
    },
    // 选人组件 - 根据专业获取对应学生
    *getStudentByMajorId({ payload, callback }: any, { call }: any): any {
      const response = yield call(service.getStudentByMajorId, payload);
      if (callback) callback(response);
    },
  },
  reducers: {},
};
